home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2283 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.0 KB  |  91 lines

  1. Path: futures.wharton.upenn.edu!ryan05
  2. From: ryan05@futures.wharton.upenn.edu (Arthur Ryan)
  3. Newsgroups: comp.lang.c++
  4. Subject: Array Assistance
  5. Date: 16 Jan 1996 21:20:43 GMT
  6. Organization: University of Pennsylvania
  7. Message-ID: <4dh4rb$ekq@netnews.upenn.edu>
  8. NNTP-Posting-Host: futures.wharton.upenn.edu
  9. X-Newsreader: TIN [version 1.2 PL2-upenn1.1]
  10.  
  11. Background:-
  12. I am in the process of eaching myself some C++ (Microsoft Version 1.5).  
  13. I am having trouble manipulating an array of integers.  
  14.  
  15. Objective:-
  16. I want to read a "CSV" file from disk in to an integer array.  Thereafter 
  17. to perform operations upon the values, currently just trying to display 
  18. the output to verify the correct reading into the array.  
  19.  
  20. Problem:-
  21. Execution results in the programme continuously looping/running and not 
  22. responding (the only indication of performance is the drive activating to 
  23. open the file for a few seconds).  When I force the programme to shut down 
  24. the message box "Process OX" followed by characters and  numbers (each 
  25. different at every running of the programme) i.e OXC37 or OXCA7.  Additionally 
  26. the 'OUTPUT' screen displays the line 'Loaded symbols for I:\APPS\WCITPRNT
  27. \CSTEXT.VBX'.  I have produced the relevant section of code below, the 
  28. remainder merely being a menu and some branching.  The size of the array 
  29. to read is 774 rows by 29 columns of positive numerics of differing lenght.  
  30.  
  31. Let me know your thoughts.  Thanks in advance.   
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. #include <iostream.h>
  40. #include <stdio.h>
  41. #include <stdlib.h>
  42. #include <fstream.h>
  43. #include <io.h>
  44.  
  45. int oda[773][28];
  46.  
  47. main()
  48. {
  49. menu display and branching based upon responese etc...
  50. }
  51.  
  52.  
  53. data_in()
  54. {
  55. int i,j;
  56.  
  57. ifstream fsin;
  58. fsin.open("A:\n&n\test.csv",ios::in);
  59.  
  60. if(fsin.bad())
  61.     {
  62.     cout << "\n*** Serious I/O error ***\n";
  63.     exit(0);
  64.     }
  65.  
  66. while (!fsin.eof())
  67.     {
  68.         for (i=0;i<774;i++);
  69.                {
  70.                    for(j=0;j<29;j++)
  71.                 {
  72.                    fsin >> oda [i][j];
  73.                    }
  74.                }
  75.     }
  76.  
  77. fsin.close();
  78.  
  79. for (i=0;i<=774;i++)
  80. {
  81.     for (j=0;j<=29;j++)
  82.     {
  83.      cout << oda [i][j];
  84.     }
  85. cout << endl;
  86. }    
  87.  
  88. return(0);
  89. }
  90.  
  91.